/*
 * @Date: 2022-03-17 02:11:12
 * @Author: 1365595476@qq.com
 * @LastEditors: 1365595476@qq.com
 * @LastEditTime: 2022-03-19 00:09:32
 */
import * as types from '../action-types'

// const initState = 0 // 初始化状态
// export default function countReducer(preState = initState, action) {
//   // 从action对象中获取：type、data
//   const { type, data } = action

//   console.log('action', data)

//   // 根据type决定如何加工数据
//   switch (type) {
//     case types.INCREMENT: // 加
//       return preState + data
//     case types.DECREMENT: // 减
//       return preState - data
//     default:
//       return preState
//   }
// }

const userInfo = {
  role: '',
  token: ''
}

export default function userReducer(preState = userInfo, action) {
  const { type, data } = action

  console.log(data)

  switch (type) {
    case types.GET_USER_INFO:
      return {
        ...preState,
        ...data
      }
    default:
      return preState
  }
}